package com.ming.controller;

import com.ming.common.Result;
import com.ming.common.validator.ValidatorUtil;
import com.ming.domain.Comment;
import com.ming.from.BookForm;
import com.ming.query.BookQuery;
import com.ming.query.CommentQuery;
import com.ming.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:何元才
 * @Desc:
 * @data:2021-05-17 04:42
 */
@RestController
@RequestMapping("comment")
public class CommentController {

    @Autowired
    private CommentService commentService;

    /**
     * 分页查询
     * @param query
     * @return
     */
    @GetMapping("page.do")
    public Object page(CommentQuery query) {
        Result rs = commentService.queryPage(query);
        return rs;
    }

    /**
     * 新增
     * @param comment
     * @return
     */
    @RequestMapping("add.do")
    public Object add(Comment comment) {
        ValidatorUtil.validator(comment);
        Result rs = commentService.add(comment);
        return rs;
    }

    /**
     * 删除
     * @param commentId
     * @return
     */
    @GetMapping("delete.do")
    public Object del(Integer commentId) {
        ValidatorUtil.validator(commentId);
        Result rs = commentService.del(commentId);
        return rs;
    }
}
